package com.zhongli.devplatform.service.impl.teacher;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhongli.devplatform.bean.PageVO;
import com.zhongli.devplatform.mapper.common.ReadNoticeMapper;
import com.zhongli.devplatform.po.common.ReadNoticePO;
import com.zhongli.devplatform.query.teacher.ReadNoticeQuery;
import com.zhongli.devplatform.service.imp.teacher.ReadNoticeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author  WuXiCheng
 * @date  2020/7/23 10:12
 * @version 1.0
 */
@Service
public class ReadNoticeServiceImpl extends ServiceImpl<ReadNoticeMapper, ReadNoticePO> implements ReadNoticeService {

    @Resource
    private ReadNoticeMapper noticeMapper;

    /**
     * @author wy
     * @param noticeQuery 查询+分页条件
     * @return 返回当前页集合
     */
    @Override
    public PageVO<ReadNoticePO> loadPageList(ReadNoticeQuery noticeQuery) {
        QueryWrapper<ReadNoticePO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(noticeQuery.getNoticeType() != null,"notice_type",noticeQuery.getNoticeType());
        queryWrapper.orderByDesc("release_time");
        ReadNoticeQuery page = noticeMapper.selectPage(noticeQuery, queryWrapper);
        return PageVO.convert(page, ReadNoticePO.class);
    }


}
